package com.taobao.yugong.translator;

import com.taobao.yugong.common.db.meta.ColumnMeta;
import com.taobao.yugong.common.db.meta.ColumnValue;
import com.taobao.yugong.common.model.record.Record;

import java.sql.Types;

/**
 * 一个迁移的例子，涵盖一些基本转换操作
 *
 * <pre>
 * 例子包含特性：
 * 1. schema/table名不同. oracle中为yugong_example_oracle，mysql中为test.yugong_example_mysql
 * 2. 字段名字不同.  oracle中的name字段，映射到mysql的display_name
 * 3. 字段逻辑处理.  mysql的display_name字段数据来源为oracle库的:name+'('alias_name+')'
 * 4. 字段类型不同.  oracle中的amount为number类型，映射到mysql的amount为varchar文本型
 * 5. 源库多一个字段. oracle中多了一个alias_name字段
 * 6. 目标库多了一个字段. mysql中多了一个gmt_move字段，(简单的用迁移时的当前时间进行填充)
 *
 * 测试的表结构：
 * // oracle表
 * create table yugong_example_oracle
 * (
 *     id NUMBER(11)  ,
 *     name varchar2(32) ,
 *     alias_name  char(32) default ' ' not null,
 *     amount number(11,2),
 *     score  number(20),
 *     text_b blob,
 *     text_c clob,
 *     gmt_create date not null,
 *     gmt_modified date not null,
 *     CONSTRAINT yugong_example_oracle_pk_id  PRIMARY   KEY (id)
 * );
 *
 * // mysql表
 * create table test.yugong_example_mysql
 * (
 *     id bigint(20) unsigned auto_increment,
 *     display_name varchar(128) ,
 *     amount varchar(32),
 *     score bigint(20) unsigned ,
 *     text_b blob,
 *     text_c text,
 *     gmt_create timestamp not null,
 *     gmt_modified timestamp not null,
 *     gmt_move timestamp not null,
 *     CONSTRAINT yugong_example_mysql_pk_id  PRIMARY KEY (id)
 * );
 * </pre>
 *
 * @author agapple 2013-10-10 下午3:28:33
 */
public class BzHireContractNewDataTranslator extends AbstractDataTranslator implements DataTranslator {

    public boolean translator(Record record) {
        record.setSchemaName("hddp-order");
        record.setTableName("bz_hire_contract_new");

        record.removeColumnByName("CONTRACT_VERSION");                                                     
        record.removeColumnByName("SIGN_DATE");                                                            
        record.removeColumnByName("HIRE_YEAR");                                                            
        record.removeColumnByName("HIRE_MONTH");                                                           
        record.removeColumnByName("AGENT_FACT_END_DATE");                                                  
        record.removeColumnByName("CONTRACT_EMPTY_START_DATE");                                            
        record.removeColumnByName("CONTRACT_EMPTY_END_DATE");                                              
        record.removeColumnByName("RECEPTION_PRICE");                                                      
        record.removeColumnByName("PAYMENT_CYCLE_CODE");                                                   
        record.removeColumnByName("TOTAL_PAYMENT");                                                        
        record.removeColumnByName("ACCOUNT_BANK");                                                         
        record.removeColumnByName("ACCOUNT_HOLDER");                                                       
        record.removeColumnByName("BANK_ACCOUNT");                                                         
        record.removeColumnByName("ACCOUNT_PHONE");                                                        
        record.removeColumnByName("HOUSE_PROPERTY_STATUS_CODE");                                           
        record.removeColumnByName("CLIENT_NAME");                                                          
        record.removeColumnByName("CLIENT_SEX");                                                           
        record.removeColumnByName("CLIENT_PHONE");                                                         
        record.removeColumnByName("CLIENT_CARD_TYPE_CODE");                                                
        record.removeColumnByName("CLIENT_CARD");                                                          
        record.removeColumnByName("PARLOR_AMOUNT");                                                        
        record.removeColumnByName("COOKROOM_AMOUNT");                                                      
        record.removeColumnByName("TOILET_AMOUNT");                                                        
        record.removeColumnByName("FRAME_CODE");                                                           
        record.removeColumnByName("DISPOSE_FRAME_CODE");                                                   
        record.removeColumnByName("REMARK");                                                               
        record.removeColumnByName("HIRE_SHOP_CODE");                                                       
        record.removeColumnByName("HIRE_SHOP");                                                            
        record.removeColumnByName("AREA_CODE");                                                            
        record.removeColumnByName("AREA_NAME");                                                            
        record.removeColumnByName("REGION_CODE");                                                          
        record.removeColumnByName("REGION_NAME");                                                          
        record.removeColumnByName("MANAGER_CODE");                                                         
        record.removeColumnByName("MANAGER_NAME");                                                         
        record.removeColumnByName("BROKER_CODE");                                                          
        record.removeColumnByName("BROKER_NAME");                                                          
        record.removeColumnByName("BROKER_PHONE");                                                         
        record.removeColumnByName("CHARGE_PHONE");                                                         
        record.removeColumnByName("MAJORDOMO_PHONE");                                                      
        record.removeColumnByName("CREATOR_ID");                                                           
        record.removeColumnByName("CREATOR_NAME");                                                         
        record.removeColumnByName("IS_LAST");                                                              
        record.removeColumnByName("IS_ROUGHCAST");                                                         
        record.removeColumnByName("STATUS_CODE");                                                          
        record.removeColumnByName("IS_RESIGN");                                                            
        record.removeColumnByName("UNOCCUPATION_DAY");                                                     
        record.removeColumnByName("IS_AUDIT");                                                             
        record.removeColumnByName("IS_DISPOSE_PROGRAM");                                                   
        record.removeColumnByName("DISTRICTS");                                                            
        record.removeColumnByName("TOWN");                                                                 
        record.removeColumnByName("DWELLING_PLACE");                                                       
        record.removeColumnByName("PROPERTY_CONDITION");                                                   
        record.removeColumnByName("OWNERSHIP_CODE");                                                       
        record.removeColumnByName("HOUSE_PROVE_NAME");                                                     
        record.removeColumnByName("IS_PLEDGE");                                                            
        record.removeColumnByName("MAX_LIVE_NUM");                                                         
        record.removeColumnByName("IS_ONLY_SAVE");                                                         
        record.removeColumnByName("SEQUENCE_NUM");                                                         
        record.removeColumnByName("REGISTER_DISTRICTS");                                                   
        record.removeColumnByName("REGISTER_TOWN");                                                        
        record.removeColumnByName("REGISTER_VILLAGE");                                                     
        record.removeColumnByName("REGISTERED");                                                           
        record.removeColumnByName("POLITICS_STATUS");                                                      
        record.removeColumnByName("NOW_DISTRICTS");                                                        
        record.removeColumnByName("NOW_OTHER");                                                            
        record.removeColumnByName("REGISTERED_ADDRESS");                                                   
        record.removeColumnByName("LOCATION_DISTRICTS");                                                   
        record.removeColumnByName("LOCATION_OTHER");                                                       
        record.removeColumnByName("OWNERSHIP");                                                            
        record.removeColumnByName("HOUSE_DISTRICTS");                                                      
        record.removeColumnByName("LOCAL_POLICE_STATION");                                                 
        record.removeColumnByName("POLICE_NAME");                                                          
        record.removeColumnByName("HIRE_TYPE");                                                            
        record.removeColumnByName("HIRE_NUM");                                                             
        record.removeColumnByName("HIRE_AREA");                                                            
        record.removeColumnByName("HIRE_POPURSE");                                                         
        record.removeColumnByName("CITY_NUM_OF_PEOPLE");                                                   
        record.removeColumnByName("OTHER_PROVINCE_NUM");                                                   
        record.removeColumnByName("HMT_NUM_OF_PEOPLE");                                                    
        record.removeColumnByName("FOREIGN_NUM_OF_PEOPLE");                                                
        record.removeColumnByName("IS_PAY_DUTY");                                                          
        record.removeColumnByName("REGISTER_RECORD");                                                      
        record.removeColumnByName("CONTRACT_OF_TENANCY");                                                  
        record.removeColumnByName("START_TENANCY_DATE");                                                   
        record.removeColumnByName("END_TENANCY_DATE");                                                     
        record.removeColumnByName("ZEITARBEIT");                                                           
        record.removeColumnByName("ZEITARBEIT_MOBILE");                                                    
        record.removeColumnByName("SUBLESSOR_NAME");                                                       
        record.removeColumnByName("SUBLESSOR_ADDRESS");                                                    
        record.removeColumnByName("SUBLESSOR_MOBILE");                                                     
        record.removeColumnByName("SUBLESSOR_CARD_TYPE");                                                  
        record.removeColumnByName("SUBLESSOR_CARD");                                                       
        record.removeColumnByName("OTHER_REMARK");                                                         
        record.removeColumnByName("ADMIN_NAME");                                                           
        record.removeColumnByName("ADMIN_CODE");                                                           
        record.removeColumnByName("RECORD_DATE");                                                          
        record.removeColumnByName("IS_INCREASE");                                                          
        record.removeColumnByName("MONTHLY_RENT");                                                         
        record.removeColumnByName("FIRST_DATE");                                                           
        record.removeColumnByName("SECOND_DATE");                                                          
        record.removeColumnByName("OPTIMIZE_TYPE");                                                        
        record.removeColumnByName("CABLE_TELEVISION_FEE");                                                 
        record.removeColumnByName("UPKEEP_COSTS");                                                         
        record.removeColumnByName("HAS_CLIENT");                                                           
        record.removeColumnByName("CONTRACT_NUM");                                                         
        record.removeColumnByName("IS_GENERATE_HOUSE_DISPOSE");                                            
        record.removeColumnByName("DELIVERY_DATE");                                                        
        record.removeColumnByName("PAYMENT_ID");                                                           
        record.removeColumnByName("PRODUCT_VERSION_ID");                                                   
        record.removeColumnByName("COMPANY_NAME");                                                         
        record.removeColumnByName("COMPANY_CHARGE_NAME");                                                  
        record.removeColumnByName("COMPANY_CHARGE_MOBILE");                                                
        record.removeColumnByName("BUILD_TYPE");                                                           
        record.removeColumnByName("PROJECT_TYPE");                                                         
        record.removeColumnByName("LOCATION_ADDRESS");                                                     
        record.removeColumnByName("PROPERTY_OWNERSHIP_CODE");                                              
        record.removeColumnByName("MONTHLY_TYPE_RECORD");                                                  
        record.removeColumnByName("MONTHLY_RECORD");                                                       
        record.removeColumnByName("RESPONSIBILITY_BOOK");                                                  
        record.removeColumnByName("CJBGSTATUS");                                                           
        record.removeColumnByName("ASSISTANT_CODE");                                                       
        record.removeColumnByName("ASSISTANT_PHONE");                                                      
        record.removeColumnByName("LURUTEL");                                                              
        record.removeColumnByName("LAST_MODIFY_NAME");                                                     
        record.removeColumnByName("HOUSE_NAME");                                                           
        record.removeColumnByName("OTHER_CUSTOM");                                                         
        record.removeColumnByName("HOUSE_FEATURE");                                                        
        record.removeColumnByName("UNIT");                                                                 
        record.removeColumnByName("FLOOR_TOTAL");                                                          
        record.removeColumnByName("FLOOR");                                                                
        record.removeColumnByName("ROOM_NO");                                                              
        record.removeColumnByName("BUILDING_NO");                                                          
        record.removeColumnByName("ZHI_BANK");                                                             
        record.removeColumnByName("HOUSE_PRODUCT");                                                        
        record.removeColumnByName("LADDER_AMOUNT");                                                        
        record.removeColumnByName("FAMILY_AMOUNT");                                                        
        record.removeColumnByName("RENTER_CYCLE_CODE");                                                    
        record.removeColumnByName("HOUSE_REGION_NAME");                                                    
        record.removeColumnByName("SUPPLY_HEAT");                                                          
        record.removeColumnByName("CH_NAME");                                                              
        record.removeColumnByName("MOBILE");                                                               
        record.removeColumnByName("SEX");                                                                  
        record.removeColumnByName("NATIVE_CITY");                                                          
        record.removeColumnByName("BIRTHDAY");                                                             
        record.removeColumnByName("EMAIL");                                                                
        record.removeColumnByName("PAPER_TYPE");                                                           
        record.removeColumnByName("PAPER_CODE");                                                           
        record.removeColumnByName("ROOM_PRICE");                                                           
        record.removeColumnByName("PHOTO_URL");                                                            
        record.removeColumnByName("DEPLOY_START_DATE");                                                    
        record.removeColumnByName("AUDIT_DATE");                                                           
        record.removeColumnByName("AUDIT_NAME");                                                           
        record.removeColumnByName("BUILDING_FRAME");                                                       
        record.removeColumnByName("SYNCHRO_IS_SUCCESS");                                                   
        record.removeColumnByName("ZIRU_COMMISSIONER_PHONE");                                              
        record.removeColumnByName("ZIRU_CHARGE_CODE");                                                     
        record.removeColumnByName("ZIRU_CHARGE_NAME");                                                     
        record.removeColumnByName("ZIRU_CHARGE_PHONE");                                                    
        record.removeColumnByName("ZIRU_MAJORDOMO_CODE");                                                  
        record.removeColumnByName("ZIRU_MAJORDOMO_NAME");                                                  
        record.removeColumnByName("ZIRU_MAJORDOMO_PHONE");                                                 
        record.removeColumnByName("YEJI_CHARGE_CODE");                                                     
        record.removeColumnByName("YEJI_CHARGE_NAME");                                                     
        record.removeColumnByName("YEJI_CHARGE_PHONE");                                                    
        record.removeColumnByName("YEJI_COMMISSIONER_CODE");                                               
        record.removeColumnByName("YEJI_COMMISSIONER_NAME");                                               
        record.removeColumnByName("YEJI_COMMISSIONER_PHONE");                                              
        record.removeColumnByName("YEJI_MAJORDOMO_CODE");                                                  
        record.removeColumnByName("YEJI_MAJORDOMO_NAME");                                                  
        record.removeColumnByName("YEJI_MAJORDOMO_PHONE");                                                 
        record.removeColumnByName("FIRST_YEAR_KONGZHI_DAY");                                               
        record.removeColumnByName("FIRST_YEAR_KONGZHI_DAYS");                                              
        record.removeColumnByName("IS_DEPLOY");                                                            
        record.removeColumnByName("HOUSE_BROKER_CODE");                                                    
        record.removeColumnByName("HOUSE_BROKER_NAME");                                                    
        record.removeColumnByName("HOUSE_BROKER_PHONE");                                                   
        record.removeColumnByName("IS_GATE_KEY");                                                          
        record.removeColumnByName("IS_PER");                                                               
        record.removeColumnByName("IS_PERFORMANCE");                                                       
        record.removeColumnByName("OUT_HOUSE_PRODUCT");                                                    
        record.removeColumnByName("LAST_MODIFY_PHONE");                                                    
        record.removeColumnByName("LOCK_TYPE");                                                            
        record.removeColumnByName("DELETE_NAME");                                                          
        record.removeColumnByName("DELETE_TIME");                                                          
        record.removeColumnByName("SHOP_CODE");                                                            
        record.removeColumnByName("SHOP_NAME");                                                            
        record.removeColumnByName("SHOP_AREA_NAME");                                                       
        record.removeColumnByName("SHOP_MANAGER_CODE");                                                    
        record.removeColumnByName("SHOP_MANAGER_NAME");                                                    
        record.removeColumnByName("SHOP_REGION_NAME");                                                     
        record.removeColumnByName("SHOP_REGION_CODE");                                                     
        record.removeColumnByName("SHOP_AREA_CODE");                                                       
        record.removeColumnByName("HOUSELURUTEL");                                                         
        record.removeColumnByName("HOUSE_EVALUATION_INTRODUCTION");                                        
        record.removeColumnByName("HOUSE_EVALUATION_CIRCUM");                                              
        record.removeColumnByName("HOUSE_EVALUATION_CELL");                                                
        record.removeColumnByName("HOUSE_EVALUATION_TRAFFIC");                                             
        record.removeColumnByName("SUPPLEMENT_STATUS");                                                    
        record.removeColumnByName("CONTRACT_CONTENT_TEXT");                                                
        record.removeColumnByName("PROPERTY_PROOF_FILES");                                                 
        record.removeColumnByName("IDENTITY_PROOF_FILES");                                                 
        record.removeColumnByName("BANK_CARD_FILES");                                                      
        record.removeColumnByName("POWER_OF_ATTORNEY");                                                    
        record.removeColumnByName("BE_PRINCIPAL_IDENTITY_PROOF");                                          
        record.removeColumnByName("RENOVATION_PERMIT_SACNNING");                                           
        record.removeColumnByName("HIRE_DEAL_REPORT");                                                     
        record.removeColumnByName("OTHER_FILES");                                                          
        record.removeColumnByName("SPARE_PARTS_REMARK");                                                   
        record.removeColumnByName("FIRST_AUDITNAME");                                                      
        record.removeColumnByName("FIRST_AUDITDATE");                                                      
        record.removeColumnByName("SUBMIT_AUDITDATE");                                                     
        record.removeColumnByName("WATER_CERTIFICATE");                                                    
        record.removeColumnByName("ELECTRICE_CERTIFICATE");                                                
        record.removeColumnByName("GAS_CERTIFICATE");                                                      
        record.removeColumnByName("VALUATION_MODEL");                                                      
        record.removeColumnByName("HIRE_BUTL_NAME");                                                       
        record.removeColumnByName("HIRE_BUTL_TEL");                                                        
        record.removeColumnByName("HIRE_BUTL_CODE");                                                       
        record.removeColumnByName("AGENT_CLIENT_ID");                                                      
        record.removeColumnByName("HIRE_CONFIG_LEADER_CODE");                                              
        record.removeColumnByName("HIRE_CONFIG_LEADER_NAME");                                              
        record.removeColumnByName("HIRE_CONFIG_LEADER_TEL");                                               
        record.removeColumnByName("SHOU_FANG_YE_WU_TUO_ZHAN_BU");                                          
        record.removeColumnByName("SHOU_FANG_YE_WU_ZU");                                                   
        record.removeColumnByName("SUO_SHU_YE_WU_TUO_ZHAN_BU");                                            
        record.removeColumnByName("SUO_SHU_YE_WU_ZU");                                                     
        record.removeColumnByName("DOOR_DISTANCE");                                                        
        record.removeColumnByName("HOUSE_OWENNER_NAME");                                                   
        record.removeColumnByName("CLIENT_EMAIL");                                                         
        record.removeColumnByName("CLIENT_ADDRESS");                                                       
        record.removeColumnByName("LAST_RENEWAL_CONTRACT_ID");                                             
        record.removeColumnByName("OWNER_SNAPSHOT_ID");                                                    
        record.removeColumnByName("OWEN_ID_BAK");                                                          
        record.removeColumnByName("CUSTOMER_REMARK");                                                      
        record.removeColumnByName("IS_DIRECT_HAR");                                                        
        record.removeColumnByName("CALCULATEPRICEMODEL_ID");                                               
        record.removeColumnByName("HIRE_WHOLE_ID");                                                        
        record.removeColumnByName("IS_SOUTHNORTH");                                                        
        record.removeColumnByName("DINGDING_CODE");                                                        
        record.removeColumnByName("DINGDING_NAME");                                                        
        record.removeColumnByName("PRINT_SEQUENCE");                                                       
        record.removeColumnByName("BROKER_ID");                                                            
        record.removeColumnByName("HOUSE_EVALUATION_PRICE");                                               
        record.removeColumnByName("PROPERTY_OWNER_ONE");                                                   
        record.removeColumnByName("OWNER_ONE_CARD");                                                       
        record.removeColumnByName("PROPERTY_OWNER_TWO");                                                   
        record.removeColumnByName("OWNER_TWO_CARD");                                                       
        record.removeColumnByName("PROPERTY_OWNER_THREE");                                                 
        record.removeColumnByName("OWNER_THREE_CARD");                                                     
        record.removeColumnByName("IS_SHARE_PROPERTY");                                                    
        record.removeColumnByName("IS_BROKER_HIRE");                                                       
        record.removeColumnByName("ZIROOM_PRODUCT");                                                       
        record.removeColumnByName("LAST_MODIFY_TIME_SYNCHRONOUS");                                         
        record.removeColumnByName("MAX_LIVING");                                                           
        record.removeColumnByName("EMERGENCY_ID");                                                         
        record.removeColumnByName("PROPERTY_TYPE");                                                        
        record.removeColumnByName("IS_HAS_DEPOSIT");                                                       
        record.removeColumnByName("DEPOSIT");                                                              
        record.removeColumnByName("IS_PRINT");                                                             
        record.removeColumnByName("PRINT_VERSION");                                                        
        record.removeColumnByName("HOUSE_SOURCE_CHANNEL");                                                 
        record.removeColumnByName("REFERRER");                                                             
        record.removeColumnByName("REFERRER_BANK_NO");                                                     
        record.removeColumnByName("REFERRER_COMMISSION");                                                  
        record.removeColumnByName("REFERRER_ID_NO");                                                       
        record.removeColumnByName("REFERRER_PHONE");                                                       
        record.removeColumnByName("SF_WHERE");                                                             
        record.removeColumnByName("REFERRER_COMPANY");                                                     
        record.removeColumnByName("BANK_AREA");                                                            
        record.removeColumnByName("AUDIT_PASS_DATE");                                                      
        record.removeColumnByName("BUSINESS_UID");                                                         
        record.removeColumnByName("ZIROOM_HIRE_CONTRACT_CODE");                                            
        record.removeColumnByName("EFFECT_DATE");                                                          
        record.removeColumnByName("CRM_CREATE_CODE");                                                      
        record.removeColumnByName("SOURCE_SYSTEM");                                                        
        record.removeColumnByName("CONTRACT_URL");                                                         
        record.removeColumnByName("CONTRACT_SIGN_URL");                                                    
        record.removeColumnByName("IS_ONLINE");                                                            
        record.removeColumnByName("CONTRACT_CG_URL");                                                      
        record.removeColumnByName("CONTRACT_SIGN_CG_URL");                                                 
        record.removeColumnByName("ZHISHOU_EMP_NAME");                                                     
        record.removeColumnByName("ZHISHOU_EMP_CODE");                                                     
        record.removeColumnByName("RENT_WAY");                                                             
        record.removeColumnByName("COMPENSATION_ACCOUNT");                                                 
        record.removeColumnByName("COMPENSATION_CYCLE");                                                   
        record.removeColumnByName("IS_DELIVERY_CONFIRMED");                                                
        record.removeColumnByName("LEASE_PERIOD");                                                         
        record.removeColumnByName("REPAIR_COSTS");                                                         
        record.removeColumnByName("REPAIR_PERIOD");                                                        
        record.removeColumnByName("OWNER_REPAIR_PERIOD");                                                  
        record.removeColumnByName("HOUSING_MAINTENANCE_DATE");                                             
        record.removeColumnByName("IS_SEND_CONFIGURATION");                                                
        record.removeColumnByName("BUSINESS_EXPAND");                                                      
        record.removeColumnByName("SUOSHU_BUSINESS_EXPAND");                                               
        record.removeColumnByName("DELIVERY_COMPLETED");                                                   
        record.removeColumnByName("ACCOUNT_ID_NUMBER");                                                    
        record.removeColumnByName("SOURCE_TYPE");                                                          
        record.removeColumnByName("CONTRACT_TEXT_BUS_ID");                                                 
        record.removeColumnByName("CONFIRM_DATE");                                                         


        ColumnMeta newDataSyncDateMeta = new ColumnMeta("new_data_sync_date", Types.TIMESTAMP);
        ColumnValue newDataSyncDateColumn = new ColumnValue(newDataSyncDateMeta, null);
        newDataSyncDateColumn.setCheck(false);// 该字段不做对比
        record.addColumn(newDataSyncDateColumn);

        return super.translator(record);
    }
}
